<?php

class Filter{
	public static function javascriptOutput($buffer){
		$lines = explode("\n", $buffer);
		$ret = "";
		foreach($lines as $line){
			$c = $line[strlen($line)-1];
			if($c == chr(10) or $c==chr(13)){
				$line = substr($line, 0, -1);
			}
			$ret .= "document.writeln(\"".addslashes($line)."\");\n";
		}
		return $ret;
	}
	
	public static function javascriptString($buffer, $type){
		$lines = explode("\n", $buffer);
		$ret = "";
		foreach($lines as $line){
			$c = $line[strlen($line)-1];
			if($c == chr(10) or $c==chr(13)){
				$line = substr($line, 0, -1);
			}
			$ret .= addslashes(trim($line));
		}
		$ret = "$('.comments-wish').html('$ret');";
		if ($type == 1){
			$ret .= '$(window).scrollTop($(\'.vow-info\').offset().top - 100);';
		}
		return $ret;
	}
}